<template>
	<view>
		<!-- <uni-section title="底部分享示例" type="line" padding> -->
		<!-- <button class="button" type="primary" @click="showPop('bottom')">点击展示详情</button> -->
		<view class="top-img">
			<!-- <image src="http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/static/home/banner@2x.png" mode="widthFix"></image> -->
			<image :src="dataList.picUrls" mode="widthFix"></image>
			<view class="mess">
				<scrollMessage :list="notice"></scrollMessage>
			</view>
		</view>

		<view class="goods-carts">
			<uni-goods-nav :fill="true" :options="options" :button-group="customButtonGroup1" @click="onClick"
				@buttonClick="buttonClick" style="margin-top: 20px;" />
		</view>
		<view class="card-fir">
			<view class="line-pop" @click="showPop('bottom')">
				<view class="line-item" v-for='item in infoList.list'>
					<image :src="item.iconUrl" mode=""></image>
					<text>{{item.title}}</text>
				</view>
				<uni-icons type="right" color='#0F999F'></uni-icons>
			</view>
			<view class="card-area">
				<view class="card-area-fir">
					<view class="titl">
						{{dataList.title}}
					</view>
					<view class="">
						<uni-icons type="location"></uni-icons>
						<text>{{dataList.cityName}}</text>
					</view>
				</view>
				<view class="price">
					¥ <text>{{dataList.salesPrice}}</text>
				</view>
				<view class="sale">
					销量 {{dataList.salesVolumn}}
				</view>
			</view>
		</view>
		<view class="card-sec">
			<view class="card-area">
				<view class="card-sec-fir">
					<view class="titl">
						服务评价
					</view>
					<view style="margin-left: -250rpx;margin-top: 15rpx; color: gray;font-size: 30rpx;">
						({{total}}条)
					</view>
					<view class="all" @click="goto('/pagesA/orderDetail/commentList')">
						<text>查看全部</text>
						<uni-icons type="right" color='#0ABA94'></uni-icons>
					</view>
				</view>
				<view v-for="(item,index) in comment" :key="index">


					<view class="card-sec-sec">
						<view class="left">
							<image :src="item.userAvatar" mode=""></image>
						</view>
						<view class="right">
							<view class="fir-txt">
								{{item.nickName}}
							</view>
							<view class="sec-txt">
								<uni-icons type="star-filled" v-for="count in item.benefitScores" color='#FFCE0A' size='20'></uni-icons>
								
								<text>{{item.benefitScores}}</text>
							</view>

						</view>
					</view>
					<view class="card-sec-thir">
						{{item.content}}
					</view>
				</view>
				<!-- <view class="card-sec-for">
					<view class="ask">
						问大家（0）
					</view>
					<view class="ask-detail">
						<view class="left">
							<image src="http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/detail/ask.png" mode="">
							</image>
							<text>如有疑问可以问大家</text>
						</view>
						<view class="right">
							去提问
						</view>

					</view>

				</view> -->

			</view>

		</view>

		<view class="card-thir">- - 我也是有底线的 - -</view>


		<!-- 调用弹窗子组件 -->
		<popCard :type='type' :status='status' :infoList="infoList" @tabtap="tabtap"></popCard>
	</view>
</template>

<script>
	import popCard from './components/pop-card/pop-card.vue'
	import requestHttp from '@/providers/essential/httpService.js'
	import api from '@/providers/API/api.js'
	import scrollMessage from './components/scroll-message/scroll-message.vue'
	import {
		onLoad
	} from '@dcloudio/uni-app';
	export default {
		components: {
			popCard,
			scrollMessage
		},

		data() {
			return {
				id: 1,
				userInfo: {},
				dataList: {},
				notice: ['dsfsdjkfbadjsfb', 'dsgjfjgdagbfergb', 'sifwgbfweghbvreilghke'],
				type: 'bottom',
				status: false,
				infoList: {
					title: '权益保障',
					list: [{
						iconUrl: 'http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/home/home_btn_sl@2x.png',
						title: '平台监管',
						content: '内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域'
					}, {
						iconUrl: 'http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/home/home_btn_sl@2x.png',
						title: '认证账户',
						content: '内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域'
					}, {
						iconUrl: 'http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/home/home_btn_sl@2x.png',
						title: '优质服务',
						content: '内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域'
					}, {
						iconUrl: 'http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/home/home_btn_sl@2x.png',
						title: '极速维权',
						content: '内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域'
					}, ]
				},
				options: [{
					icon: 'home',
					text: '首页'
				}, {
					icon: 'chat',
					text: '客服',
					infoBackgroundColor: '#007aff',
					infoColor: "#f5f5f5",
					type: 'contact'
				}, {
					icon: 'cart',
					text: '投诉'
				}],
				customButtonGroup1: [{
					text: '立即预约',
					backgroundColor: 'linear-gradient(90deg, #0ABA94, #0ABA94)',
					color: '#fff'
				}],
				comment: [],
				total:0
			}

		},
		methods: {
			goto(e){
				uni.navigateTo({
					url:e
				})
			},
			getComment() {
				requestHttp.getData('/app-api/pz/service-manage-comment/page', {
					serviceManageId: 3
				}).then((res) => {
					// this.comment = res.data.list
					this.comment.push(res.data.list[0])
					this.total=res.data.total
				})
			},
			onClick(e) {
				if (e.content.icon == 'home') {
					uni.reLaunch({
						url: '/pages/accompany-tmp/index/index'
					})
				} else if (e.content.icon == 'cart') {
					if(this.userInfo.nickname){
						uni.navigateTo({
							url: '/pages/accompany-tmp/complaint/complaint?id=' + this.id + '&merchantId=' + this
								.dataList.merchantId
						})
					}else{
						uni.navigateTo({
							url:'/pages/accompany-tmp/my/login/login'
						})
					}
					
				} else {
					uni.navigateTo({
						url: e.content.page
					})
				}
			},
			buttonClick(e) {
				console.log(this.userInfo)
				if(!this.userInfo.nickname){
					uni.navigateTo({
						url:'/pages/accompany-tmp/my/login/login'
					})
				}
				console.log(e.content.text, 'text')
				let clickText = e.content.text
				if (clickText === '立即预约') {
					uni.navigateTo({
						url: '/pages/accompany-tmp/index/createOrder/createOrder?dataList=' + encodeURIComponent(
							JSON.stringify(this.dataList))
					})
				}
				this.options[2].info++
			},
			showPop(type) {
				this.type = type
				this.status = true
				console.log(this.type, this.status, 'this.status')
			},
			// 子组件传给父组件
			tabtap(status) {
				this.status = status
			},
			getServiceManage() {
				let code = '1'
				let url = api.getServiceManage
				let param = {
					id: this.id
				}
				console.log(api.getServiceManage, 'getServiceManage')
				requestHttp.getData(url, param).then((res) => {
					if (res.code == 0) {
						this.dataList = res.data
						uni.setStorageSync('salesPrice', res.data.salesPrice)
						// categoryId: 28
						// categoryName: null
						// city: "110100"
						// cityName: null
						// content: "<p>服务测试服务测试服务测试服务测试服务测试服务测试服务测试服务测试服务测试服务测试服务测试<img src="http://49.234.34.70:8083/admin-api/infra/file/5/get/20230815144006238UIOscf.jpg" alt="image" data-href="http://49.234.34.70:8083/admin-api/infra/file/5/get/20230815144006238UIOscf.jpg" style=""/></p>"
						// createTime: 1692081644000
						// id: 1
						// merchant: "1"
						// originPrice: 362
						// picUrls: "http://49.234.34.70:8083/admin-api/infra/file/5/get/20230815144028208NZyvKW.jpeg"
						// province: "110000"
						// provinceName: null
						// salesPrice: 269
						// salesVolumn: 1
						// title: "服务测试"

					} else if (res.msg) {
						uni.showToast({
							title: res.msg, //显示的文字 
							icon: 'none'
						})

					}

				})
			}


		},
		onReady() {
			let userInfo = uni.getStorageSync('userInfo')
			if (userInfo) {
				this.userInfo = userInfo
			} else {

			}
			this.getServiceManage()

		},
		onLoad(option) { //option为object类型，会序列化上个页面传递的参数
			console.log(option.id, 'dididid'); //打印出上个页面传递的参数。
			this.id = option.id
			this.getComment()
		}



	}
</script>

<style lang="scss">
	.example-body {
		padding: 0;
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
	}

	.goods-carts {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		position: fixed;
		left: 0;
		right: 0;
		/* #ifdef H5 */
		left: var(--window-left);
		right: var(--window-right);
		/* #endif */
		bottom: 0;
	}

	.top-img {
		position: relative;
		background-color: #F5F7FA;
		// background-image: url('http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static/static/home/banner@2x.png');
		padding: 20rpx;

		image {
			width: 100%;
		}

		.mess {
			position: absolute;
			bottom: 60rpx;
			left: 20rpx;
			width: 100%;
			height: 60rpx;
		}
	}

	.card-fir {
		background-color: #F5F7FA;
		padding-bottom: 20rpx;
		// padding-top: 40rpx;

	}

	.line-pop {
		margin: 0 20rpx;
		height: 60rpx;
		display: flex;
		align-items: center;
		background-color: #C8F6EC;
		border-radius: 10rpx;

		.line-item {
			display: flex;
			align-items: center;
			padding: 0 15rpx;

		}

		// justify-content: center;
		image {
			width: 32rpx;
			height: 32rpx;
		}

		text {
			padding-left: 5rpx;
			font-size: 26rpx;
			color: #0F999F;

		}


	}

	.card-area {

		border-radius: 10rpx;
		margin: 0 20rpx;
		background-color: #fff;

		.card-area-fir {
			display: flex;
			justify-content: space-between;
			background-color: #fff;
			padding: 15rpx 20rpx;

			.titl {
				font-size: 46rpx;

			}

		}

		.price {
			color: red;
			padding: 15rpx 20rpx;

			text {
				font-size: 46rpx;
			}
		}

		.sale {
			color: #999999;
			padding: 15rpx 20rpx;
			font-size: 28rpx;
		}
	}

	.card-sec {
		background-color: #F5F7FA;
		// margin:20rpx;

		.card-sec-fir {
			border-radius: 20rpx;
			display: flex;
			justify-content: space-between;
			background-color: #fff;
			padding: 20rpx;

			// margin-top:20rpx;
			.titl {
				font-size: 42rpx;
				font-weight: bold;
			}

			.all {
				color: #0ABA94;
				// padding-right:20rpx
			}

		}

		.card-sec-sec {
			display: flex;
			padding: 20rpx;

			image {
				height: 80rpx;
				width: 80rpx;
				border-radius: 50%;
			}

			.right {
				padding-left: 20rpx;

				.fir-txt {
					font-size: 36rpx;
					font-weight: bold;
				}

				.sec-txt {
					display: flex;

					text {
						padding-right: 5rpx;
						font-size: 32rpx;
						color: #FFCE0A;
					}
				}
			}

		}

		.card-sec-thir {
			font-size: 36rpx;
			color: #999999;
			padding: 10rpx 25rpx;
			margin-bottom: 40rpx;
		}

	}

	.card-sec-for {
		padding-top: 20rpx;
		margin: 0 20rpx;
		border-top: 3rpx solid #F5F7FA;
		height: 100%;

		.ask-detail {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 20rpx;


			.left {
				display: flex;
				align-items: center;
				padding-bottom: 20rpx;

				image {
					height: 60rpx;
					width: 60rpx;
					padding-right: 20rpx;
				}
			}

			.right {
				height: 60rpx;
				width: 150rpx;
				line-height: 60rpx;
				text-align: center;
				border: 2rpx solid #0ABA94;
				border-radius: 30rpx;
				color: #0ABA94;

			}
		}

	}

	.card-thir {
		background-color: #F5F7FA;
		padding-bottom: 120rpx;
		// color:#BFBFBF;
		font-size: 28rpx;
		text-align: center;
		padding-top: 20rpx;

	}
</style>